Skip to content

test: add an offline OBP-API contract and a v5.1.0 version floor - #187

Open
hongwei1 wants to merge 10 commits into
OpenBankProject:developfrom
hongwei1:test/obp-api-contract
Open

hongwei1 wants to merge 10 commits into
OpenBankProject:developfrom
hongwei1:test/obp-api-contract

Conversation

@hongwei1

@hongwei1 hongwei1 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

This adds an offline contract between API Explorer II and OBP-API, so a breaking OBP-API change shows up in npm test instead of in a running Explorer. obp-api-contract/contract.json lists the 28 fixed OBP-API calls the front end and the server make (verb, path, source file, the text that makes the call, the version constants the path is built from, and the response fields the code reads), and obp-api-contract/snapshot.json records what OBP-API documents for each of them; refresh it with python3 -I obp-api-contract/snapshot.py --base https://k8s.openbankproject.com (public resource docs, no credentials). server/test/obpApiContract.test.ts fails when a listed call or version constant is no longer in its source, when a line that builds an OBP-API path is not listed, when the snapshot does not match the contract, or when a call's endpoint or a field the code reads is not documented, unless the entry records it as a known gap (undocumented_fields), and it also fails once such a gap gets documented, so the list only shrinks. server/test/obpApiVersion.test.ts fails on any obp/vX.Y.Z or quoted version literal below v5.1.0 in the sources, since deployments can switch those versions off; there are none today.

The recorded gaps are fields OBP-API returns but does not describe in its typed response docs: the resource docs (also for Domain APIs), the message-docs JSON schema, and well_known_uris of /obp/v5.1.0/well-known, whose doc shows only jwks_uris. Not covered yet: paths the user picks while browsing (Try It and the generic /api/get|create|update|delete proxy) and the gRPC page. .github/workflows/tests.yml runs the whole vitest suite (140 tests, no server and no settings needed) on every pull request. server/test/OBPClientService.test.ts is removed: it called getOAuthHeader, which the move to OAuth2 deleted, and needed VITE_OBP_API_HOST to be set.

Scans src, server, Dockerfiles, scripts and the example configs for obp/vX.Y.Z and quoted version literals below v5.1.0; any hit must be listed in BELOW_V510 with a reason.
obp-api-contract/contract.json records verb, path, source, needles, the version constants each path is built from, and the response fields the code reads, for the 28 fixed calls of the front end and the server.
snapshot.py reads the public resource docs of each version in contract.json and records the operation id and response fields of every call; snapshot.json was taken from k8s.openbankproject.com (OBP-API v7.0.0, 474d4bcc).
server/test/obpApiContract.test.ts checks that every needle and version constant is in its source, that every line building an OBP-API path is listed, that the snapshot matches the contract, and that every call and every field it reads is documented unless recorded as a gap.
A literal path segment also matches a documented placeholder, so a call whose own endpoint is gone could match a neighbouring endpoint when the snapshot is retaken, and the tests would pass against the wrong fields. snapshot.py now compares each call's operation with the snapshot.json already on disk: if one differs it lists the calls and writes nothing, unless --accept-rebind is given. A path with no /obp/vX.Y.Z prefix is recorded as missing and unversioned instead of stopping the script. The file is the same in every repository that keeps an OBP-API contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant